<?php
    session_start();
    include "function/config.php";
    include "function/functionPHP.php";
    include "class/address.class.php";
    include "class/coop.class.php";
    include "class/crop.class.php";
    include "class/date.class.php";
    include "class/farm.class.php";
    include "class/member.class.php";
    
    $page=$_GET["page"];
    if(!ofAuthenticated()){
        if(memAuthenticated()){
            $page="member/memberDetail";
            $memID=$_SESSION["memAuthen"]["memID"];
        }
    }

    include "./template/general/htmlHeader.php";

    if($_GET["page"]=="denied"){
        ?>
<script type="text/javascript">
    alert("Permission Denied!");
    location.replace(".");
</script>
        <?php
    }else if(memAuthenticated() || ofAuthenticated()){
        include TEMPLATE_DIR."/navBar.php";

        $phaseID=$_GET["phaseID"];
        $page=$_GET["page"];
        if($page!=""){
            include $_GET["page"].".php";
        }else{
            if(ofAuthenticated()){
                include "home/ofHome.php";
            }else{
                include "member/memberDetail.php";
            }
        }
        include "template/general/htmlFooter.php";

    }else{
        include 'member/authen/authenForm.php';
    }